package LeetCode.LC58;

/**
 * @author corn
 * @create 2020-07-17-20:23
 */
public class LengthOfLastWord58 {

}
class Solution7 {
    public int lengthOfLastWord(String s) {
        int end = s.length() - 1;
        if(end < 0) return 0;
        int start = end;
        while(start >= 0 && s.charAt(start) != ' ') start--;
        return end - start;
        //个人想法：用时1ms
//        if(s ==null){
//            return 0;
//        }
//        s = s.trim();
//        String[] str = s.split(" ");
//        return str[str.length-1].length();
    }
}
